﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using AMStudio.Common;
using AMStudio.Log;
using com.itac.easyworks.api.client.mii;
using com.itac.easyworks.api.idl;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace AMStudio.Driver
{
    [Serializable]
    public class TraceRealConfig
    {
        private string hardwareName = string.Empty;
        public string HardwareName
        {
            get { return hardwareName; }
            set { hardwareName = value; }
        }
        private string hardwareEvent = string.Empty;
        public string HardwareEvent
        {
            get { return hardwareEvent; }
            set { hardwareEvent = value; }
        }

        private static TraceRealConfig defaultConfig = null;
        public static TraceRealConfig Default
        {
            get
            {
                if (defaultConfig == null)
                {
                    SimpleConfigProvider<TraceRealConfig> myConfigProvider = new SimpleConfigProvider<TraceRealConfig>(@"Config\Machine\TraceConfig.xml");
                    defaultConfig = myConfigProvider.GetConfig();
                    myConfigProvider.SaveConfig(defaultConfig); ;
                }
                return defaultConfig;
            }
        }
        private ApiSessionValidationStruct validationSetting = new ApiSessionValidationStruct("R06111020", "", "", false, true, "R06111020");
        public ApiSessionValidationStruct ValidationSetting
        {
            get { return validationSetting; }
            set { validationSetting = value; }
        }


        private ApiSessionValidationStruct dipatchValidationSetting = new ApiSessionValidationStruct("R06210020", "", "", false, true, "R06210020");
        public ApiSessionValidationStruct DipatchValidationSetting
        {
            get { return dipatchValidationSetting; }
            set { dipatchValidationSetting = value; }
        }

        private ApiSessionValidationStruct bomCheckSetting = new ApiSessionValidationStruct("R06111010", "", "", false, true, "R06111010");
        public ApiSessionValidationStruct BomCheckSetting
        {
            get { return bomCheckSetting; }
            set { bomCheckSetting = value; }
        }

        private string attributeCodeForContext = "RSU_GLOBALA_ICID";
        public string AttributeCodeForContext
        {
            get { return attributeCodeForContext; }
            set { attributeCodeForContext = value; }
        }

        private ErrorCodeAttributeCodeMapping errorCodeMapping = new ErrorCodeAttributeCodeMapping();
        public ErrorCodeAttributeCodeMapping ErrorCodeMapping
        {
            get { return errorCodeMapping; }
            set { errorCodeMapping = value; }
        }

        private appendAttributeToSerialNumberConfig appendAttributeToSerialNumber = new appendAttributeToSerialNumberConfig();
        public appendAttributeToSerialNumberConfig AppendAttributeToSerialNumber
        {
            get { return appendAttributeToSerialNumber; }
            set { appendAttributeToSerialNumber = value; }
        }
        private getAttributeForSerialNumberConfig getAttributeForSerialNumber = new getAttributeForSerialNumberConfig();
        public getAttributeForSerialNumberConfig GetAttributeForSerialNumber
        {
            get { return getAttributeForSerialNumber; }
            set { getAttributeForSerialNumber = value; }
        }
        private getSerialNumbersForAttributeConfig getSerialNumbersForAttribute = new getSerialNumbersForAttributeConfig();
        public getSerialNumbersForAttributeConfig GetSerialNumbersForAttribute
        {
            get { return getSerialNumbersForAttribute; }
            set { getSerialNumbersForAttribute = value; }
        }
        private getNextSerialNumberForWorkOrderConfig getNextSerialNumberForWorkOrder = new getNextSerialNumberForWorkOrderConfig();
        public getNextSerialNumberForWorkOrderConfig GetNextSerialNumberForWorkOrder
        {
            get { return getNextSerialNumberForWorkOrder; }
            set { getNextSerialNumberForWorkOrder = value; }
        }
        private getSnrUploadInfoConfig getSnrUploadInfo = new getSnrUploadInfoConfig();
        public getSnrUploadInfoConfig GetSnrUploadInfo
        {
            get { return getSnrUploadInfo; }
            set { getSnrUploadInfo = value; }
        }
        private removeAttributeFromSerialNumberConfig removeAttributeFromSerialNumber = new removeAttributeFromSerialNumberConfig();
        public removeAttributeFromSerialNumberConfig RemoveAttributeFromSerialNumber
        {
            get { return removeAttributeFromSerialNumber; }
            set { removeAttributeFromSerialNumber = value; }
        }
        private uploadStateAndFailureDataConfig uploadStateAndFailureData = new uploadStateAndFailureDataConfig();
        public uploadStateAndFailureDataConfig UploadStateAndFailureData
        {
            get { return uploadStateAndFailureData; }
            set { uploadStateAndFailureData = value; }
        }
        private uploadStateConfig uploadState = new uploadStateConfig();
        public uploadStateConfig UploadState
        {
            get { return uploadState; }
            set { uploadState = value; }
        }
    }

    [Serializable]
    public class ErrorCodeAttributeCodeMapping
    {
        private string pCBMounting = "1803";
        public string PCBMounting
        {
            get { return pCBMounting; }
            set { pCBMounting = value; }
        }
        private string pressfit = "1804";
        public string Pressfit
        {
            get { return pressfit; }
            set { pressfit = value; }
        }
        private string pinCheck = "1805";
        public string PinCheck
        {
            get { return pinCheck; }
            set { pinCheck = value; }
        }
        private string potting = "1806";
        public string Potting
        {
            get { return potting; }
            set { potting = value; }
        }
        private string oven = "1807";
        public string Oven
        {
            get { return oven; }
            set { oven = value; }
        }
        private string tester = "1808";
        public string Tester
        {
            get { return tester; }
            set { tester = value; }
        }
        private string screw = "1809";
        public string Screw
        {
            get { return screw; }
            set { screw = value; }
        }
        private string laser = "1810";
        public string Laser
        {
            get { return laser; }
            set { laser = value; }
        }
        private string scanner = "1811";
        public string Scanner
        {
            get { return scanner; }
            set { scanner = value; }
        }
        private string trace = "1812";
        public string Trace
        {
            get { return trace; }
            set { trace = value; }
        }

        public string GetAttributeCodeAccordingToFailCode(int failCode)
        {
            switch (failCode)
            {
                case 3:
                    return PCBMounting;
                case 4:
                    return Pressfit;
                case 5:
                    return PinCheck;
                case 6:
                    return Potting;
                case 7:
                    return Oven;
                case 8:
                    return Tester;
                case 9:
                    return Screw;
                case 10:
                    return Laser;
                case 11:
                    return Scanner;
                case 12:
                    return Trace;
                default:
                    return Trace;
            }
        }
    }


    [Serializable]
    public class appendAttributeToSerialNumberConfig
    {
        private string attributeCode_Pass = "CUST_SERIAL_NO";
        public string AttributeCode_Pass
        {
            get { return attributeCode_Pass; }
            set { attributeCode_Pass = value; }
        }
        private string attributeCode_Fail = "RSU_ASS_FAILURE";
        public string AttributeCode_Fail
        {
            get { return attributeCode_Fail; }
            set { attributeCode_Fail = value; }
        }
    }
    [Serializable]
    public class getAttributeForSerialNumberConfig
    {
        private int snrAttributeInfosSize = 1;
        public int SnrAttributeInfosSize
        {
            get { return snrAttributeInfosSize; }
            set { snrAttributeInfosSize = value; }
        }
        private string attributeCode_Fail = "RSU_ASS_FAILUR";
        public string AttributeCode_Fail
        {
            get { return attributeCode_Fail; }
            set { attributeCode_Fail = value; }
        }
    }
    [Serializable]
    public class getSerialNumbersForAttributeConfig
    {
        private string attributeCode = "CUST_SERIAL_NO";
        public string AttributeCode
        {
            get { return attributeCode; }
            set { attributeCode = value; }
        }
    }
    [Serializable]
    public class getNextSerialNumberForWorkOrderConfig
    {
        private int serialNumberArraySize = 1;
        public int SerialNumberArraySize
        {
            get { return serialNumberArraySize; }
            set { serialNumberArraySize = value; }
        }
    }
    [Serializable]
    public class getSnrUploadInfoConfig
    {
        private int processLayer = 2;
        public int ProcessLayer
        {
            get { return processLayer; }
            set { processLayer = value; }
        }
        private int serialnumberPos = 1;
        public int SerialnumberPos
        {
            get { return serialnumberPos; }
            set { serialnumberPos = value; }
        }
        private int checkProcessStep = 1;
        public int CheckProcessStep
        {
            get { return checkProcessStep; }
            set { checkProcessStep = value; }
        }
    }
    [Serializable]
    public class removeAttributeFromSerialNumberConfig
    {
        private string attributeCode = "RSU_ASS_FAILURE";
        public string AttributeCode
        {
            get { return attributeCode; }
            set { attributeCode = value; }
        }
    }
    [Serializable]
    public class uploadStateAndFailureDataConfig
    {
        //private string stationNr = "R04111010";
        //public string StationNr
        //{
        //    get { return stationNr; }
        //    set { stationNr = value; }
        //}
        private int processLayer = 2;
        public int ProcessLayer
        {
            get { return processLayer; }
            set { processLayer = value; }
        }
        private string productNo = "-1";
        public string ProductNo
        {
            get { return productNo; }
            set { productNo = value; }
        }
        private string productRev = "-1";
        public string ProductRev
        {
            get { return productRev; }
            set { productRev = value; }
        }
        private string serialNumberPos = "1";
        public string SerialNumberPos
        {
            get { return serialNumberPos; }
            set { serialNumberPos = value; }
        }
        private int serialNumberState = 1;
        public int SerialNumberState
        {
            get { return serialNumberState; }
            set { serialNumberState = value; }
        }
        private int duplicateSerialNumber = 0;
        public int DuplicateSerialNumber
        {
            get { return duplicateSerialNumber; }
            set { duplicateSerialNumber = value; }
        }
        private int size = 1;
        public int Size
        {
            get { return size; }
            set { size = value; }
        }
        private string compName = "RSU";
        public string CompName
        {
            get { return compName; }
            set { compName = value; }
        }
        private string compPartNo = "-1";
        public string CompPartNo
        {
            get { return compPartNo; }
            set { compPartNo = value; }
        }
        private string failureCause = "-1";
        public string FailureCause
        {
            get { return failureCause; }
            set { failureCause = value; }
        }
        private string infoText = "-1";
        public string InfoText
        {
            get { return infoText; }
            set { infoText = value; }
        }
        private int repair = 0;
        public int Repair
        {
            get { return repair; }
            set { repair = value; }
        }
    }
    [Serializable]
    public class uploadStateConfig
    {
        //private string stationNr = "R04111010";
        //public string StationNr
        //{
        //    get { return stationNr; }
        //    set { stationNr = value; }
        //}
        private int processLayer = 2;
        public int ProcessLayer
        {
            get { return processLayer; }
            set { processLayer = value; }
        }
        private string serialNumberRefPos ="1";
        public string SerialNumberRefPos
        {
            get { return serialNumberRefPos; }
            set { serialNumberRefPos = value; }
        }
        private int duplicateSerialNumber = 0;
        public int DuplicateSerialNumber
        {
            get { return duplicateSerialNumber; }
            set { duplicateSerialNumber = value; }
        }
        private int checkActiveWorkOrder = 0;
        public int CheckActiveWorkOrder
        {
            get { return checkActiveWorkOrder; }
            set { checkActiveWorkOrder = value; }
        }
    }
}
